﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace xiangmu1
{
    public partial class H_Y_CZJL : Form
    {
        public H_Y_CZJL()
        {
            InitializeComponent();
        }
       
        private void Form5_Load(object sender, EventArgs e)
        {
            LeiXingXiaLa();
            ChaXunHuiYuan();
          
        }
        public void ChaXunHuiYuan()
        {
            string name = txt_kahao.Text;
            int type = cbo_leixing.SelectedIndex;
            string sql = @" select  v.VpKaHao,s.PayName,c.CzMoney,c.Czdate,c.CzPerson from CongZInfo c,PayClass s,VipInfo v where c.CzKaHao=v.VpId and c.CzClass=s.PayId and 1=1";
            
            if (!string.IsNullOrEmpty(name))
            {
                sql += string.Format(" and VpKaHao like '%{0}%' ",name);
            }
            int leixing = Convert.ToInt32(cbo_leixing.SelectedValue);
            if (leixing != 0)
            {
                sql += string.Format(" and CzClass=" + leixing);
            }
            DataTable dt = FrmHotel.DBHelper.SelectForTable(sql);
            dataGridView1.DataSource = dt;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ChaXunHuiYuan();
        }
        public void LeiXingXiaLa()
        {
 
            string sql2 = "select * from  PayClass";
            DataTable dt2 = FrmHotel.DBHelper.SelectForTable(sql2);
            DataRow dr2 = dt2.NewRow();
            dr2["PayId"] = 0;
            dr2["PayName"] = "请选择";
            dt2.Rows.InsertAt(dr2, 0);
            this.cbo_leixing.DisplayMember = "PayName";
            this.cbo_leixing.ValueMember = "PayId";
            this.cbo_leixing.DataSource = dt2;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        private void cbo_leixing_SelectedIndexChanged(object sender, EventArgs e)
        {
            ChaXunHuiYuan();
        }

        private void txt_kahao_TextChanged(object sender, EventArgs e)
        {
            ChaXunHuiYuan();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
